package com.koron.sinoprobe.web.ledger.bean.enums;

import com.koron.sinoprobe.config.Constants;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author jzp
 * @since 2022/4/13
 */
@AllArgsConstructor
@Getter
public enum ProjectEnum {

    ESTABLISH(Constants.SP_PROJECT_ACTION.ESTABLISH,"w_sp_establish"),
    DESIGN(Constants.SP_PROJECT_ACTION.DESIGN,"w_sp_design"),
    DIVISION(Constants.SP_PROJECT_ACTION.DIVISION,"w_sp_division"),
    BUDGETREVIEW(Constants.SP_PROJECT_ACTION.BUDGETREVIEW,"w_sp_budget_review"),
    CONSTRUCTION(Constants.SP_PROJECT_ACTION.CONSTRUCTION,"w_sp_construction_plan"),
    APPCEPT(Constants.SP_PROJECT_ACTION.APPCEPT,"w_sp_appcept"),
    SETTLEMENT_AUDIT(Constants.SP_PROJECT_ACTION.SETTLEMENT_AUDIT,"w_sp_settlement_audit"),
    WARRANTY_ACCEPT(Constants.SP_PROJECT_ACTION.WARRANTY_ACCEPT,"w_sp_warranty_accept"),
    END_APPRAISE(Constants.SP_PROJECT_ACTION.END_APPRAISE,"w_sp_end_appraise"),
    PURCHASE_ESTABLISH(Constants.SP_PROJECT_ACTION.PURCHASE_ESTABLISH,"w_sp_purchase_establish"),
    PURCHASE_ACCEPT(Constants.SP_PROJECT_ACTION.PURCHASE_ACCEPT,"w_sp_purchase_accept"),
    ;

    // 专项工程操作类型 字典：sp_project_action
    private String projectAction;

    // 表名
    private String tableName;

    public static String getTableName(String projectAction) {
        for (ProjectEnum value : values()) {
            if (value.getProjectAction().equals(projectAction)) {
                return value.getTableName();
            }
        }
        throw new IllegalArgumentException("参数projectAction不在字典sp_project_action中");
    }
}
